package com.ihisun.tmhcms.utils;

import lombok.Data;

@Data
public class ResponseVo<T> {

    private static final long serialVersionUID = 1L;

    private Integer code;
    private String msg;
    private T data;

    public static ResponseVo fail() {
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(500);
        responseVo.setMsg("服务器错误！！！");
        return responseVo;
    }

    public static ResponseVo fail(String msg) {
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(401);
        responseVo.setMsg("未授权");
        return responseVo;
    }

    public static <T> ResponseVo<T> ok(T data) {
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(200);
        responseVo.setMsg("查询到数据");
        responseVo.setData(data);
        return responseVo;
    }

    public static <T> ResponseVo<T> isNull(T data) {
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(200);
        responseVo.setMsg("没有查询到数据");
        responseVo.setData(data);
        return responseVo;
    }
    public static <T> ResponseVo<T> ok() {
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(200);
        responseVo.setData("操作成功");
        return responseVo;
    }

    public static ResponseVo error() {
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(200);
        responseVo.setMsg("操作失败");
        return responseVo;
    }
}
